package de.hub.sar.itsec.sslfetcher;

import java.util.concurrent.ThreadFactory;
import de.hub.sar.itsec.sslfetcher.fetcher.IFetcher;
import de.hub.sar.itsec.sslfetcher.fetcher.SSLFetcher;
import de.hub.sar.itsec.sslfetcher.saver.CertSaver;
import de.hub.sar.itsec.sslfetcher.saver.ISaver;

public class LoaderThreadFactory implements ThreadFactory {
	private final String outPath;
	
	public LoaderThreadFactory(final String outPath) {
		this.outPath = outPath;
	}
	
	@Override
	public Thread newThread(Runnable runnable) {
		IFetcher fetcher;
		ISaver saver;
		
		fetcher = new SSLFetcher();
		saver = new CertSaver(this.outPath, ".pem");
		
		return new LoaderThread(runnable, fetcher, saver);
	}

}
